package cn.com.huzo.service.trade.impl;

import cn.com.huzo.model.entities.trade.InspectionJournalLinesCertificationHeaderEntity;
import cn.com.huzo.repository.trade.InspectionJournalLinesCertificationHeaderRepository;
import cn.com.huzo.repository.trade.InspectionJournalLinesCertificationLinesRepository;
import cn.com.huzo.service.trade.InspectionJournalLinesCertificationHeaderManager;
import huzofw.common.util.annotations.WriteLog;
import huzofw.service.impl.GenericManagerImpl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 化检日记账合格证管理服务对象类实现。
 *
 * @author 范学春
 */
@Service("InspectionJournalLinesCertificationHeaderManager")
public class InspectionJournalLinesCertificationHeaderManagerImpl extends GenericManagerImpl<InspectionJournalLinesCertificationHeaderEntity, String>
        implements InspectionJournalLinesCertificationHeaderManager {

    @Resource(name = "InspectionJournalLinesCertificationHeaderRepository")
    private InspectionJournalLinesCertificationHeaderRepository _dao;

    @Resource(name = "InspectionJournalLinesCertificationLinesRepository")
    private InspectionJournalLinesCertificationLinesRepository _linesDao;

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public List<InspectionJournalLinesCertificationHeaderEntity> fetchCertificationByHeaderKey(Long headerKey) throws Exception {
        return _dao.fetchByHeaderKey(headerKey);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public Map<String, Object> fetchContentByLinesKey(String linesKey) throws Exception {
        Map<String, Object> rtnValue = new HashMap();

        rtnValue.put("HeaderEntity", _dao.fetchByLinesKey(linesKey));
        rtnValue.put("LinesList", _linesDao.fetchByHeaderKey(linesKey));

        return rtnValue;
    }

    /**
     * {@inheritDoc}
     *
     */
    @Override
    @WriteLog(modelName = "贸易管理→化检日记账合格证", typeOfOperated = "增加")
    public String insert(InspectionJournalLinesCertificationHeaderEntity instance) throws Exception {
        return _dao.insert(instance);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    @WriteLog(modelName = "贸易管理→化检日记账合格证", typeOfOperated = "更新")
    public Integer update(InspectionJournalLinesCertificationHeaderEntity instance) throws Exception {
        return _dao.update(instance);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    @WriteLog(modelName = "贸易管理→化检日记账合格证", typeOfOperated = "删除")
    public List<InspectionJournalLinesCertificationHeaderEntity> deleteLines(InspectionJournalLinesCertificationHeaderEntity instance) throws Exception {
        _dao.delete(instance.getLinesId());
        return _dao.fetchByHeaderKey(instance.getHeaderId());
    }
}
